package com.vzaar.examples;

import java.io.File;

import com.vzaar.Vzaar;
import com.vzaar.VzaarException;
import com.vzaar.Vzaar.Profile;

/**
 * Example showing the video upload command.
 * 
 * @author Marc G. Smith
 */
public class VideoUploadExample 
{
	///////////////////////////////////////////////////////////////////////////

	public static void main(String[] args) {
		try {
			ParameterHelper helper = new ParameterHelper(args);
			args = helper.getRemainingArgs();
			if(args.length != 4) {
				printUsage();
				System.exit(1);
				return;
			}
			
			Vzaar vzaar = helper.createVzaar();
			vzaar.uploadVideo(
				args[0],
				args[1],
				Profile.toEnum(Integer.parseInt(args[2])),
				new File(args[3]),
				new VideoUploadCallbackExample());
		}
		catch(VzaarException e) {
			System.err.println("Error: " + e.getMessage());
			System.exit(2);
		}
		catch(Exception e) {
			printUsage();
			System.exit(1);
		}
		
	}
	
	///////////////////////////////////////////////////////////////////////////

	private static final  void printUsage() 
	{
		System.out.println("Usage: vzaar-upload " +
			"[-debug] [-ssl3] [-transport h3|h4] [-url <url>] [-oatoken <token>] [-oasecret <secret>] " +
			" <title> <description> <profile> <video>\n");
		System.out.println("   <title>             " +
			"The video title");
		System.out.println("   <description>       " +
			"The video description");
		System.out.println("   <profile>           " +
			"The video size profile: 1=Small, 2=Medium, 3=Large, 4=HD, 5=Original");
		System.out.println("   <video  >           " +
			"The video file to upload");
		System.out.println("   -debug              " +
			"Turn on debug out");
		System.out.println("   -url <url>          " +
			"The API URL to use. Default is https://vzaar.com.");
		System.out.println("   -oatoken <token>    " +
			"The OAuth token. This is typically your vzaar user name.");
		System.out.println("   -oasecret <secret>  " +
			"The OAuth secret as generated by vzaar");
		System.out.println("   -ssl3               " +
			"Use SSL3 only, to be used with authentication issues with https://vzaar.com");
		System.out.println("   -transport hc3|hc4  " +
			"The http client library to use, either version 3 or version 4");
		System.out.println("\n   The debug, url, oatoken and oasecret can be " +
			"configured to defaults in the vzaar-config.sh and vzaar-config.bat " +
			"files. Using the command line will override these settings.");
	}
	
	///////////////////////////////////////////////////////////////////////////
}
